home *** CD-ROM | disk | FTP | other *** search
- // DirPickDlg.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "DirPick.h"
- #include "DirPickDlg.h"
- #include "picture.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CDirPickDlg dialog
-
- CDirPickDlg::CDirPickDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CDirPickDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDirPickDlg)
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
-
- void CDirPickDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDirPickDlg)
- DDX_Control(pDX, IDC_BFC, m_bfc);
- DDX_Control(pDX, IDC_BFP, m_bfp);
- DDX_Control(pDX, IDC_CAPTION, m_caption);
- DDX_Control(pDX, IDC_DGBD, m_dgbd);
- DDX_Control(pDX, IDC_RFSA, m_rfsa);
- DDX_Control(pDX, IDC_ROFSD, m_rofsd);
- DDX_Control(pDX, IDC_ROOT, m_root);
- DDX_Control(pDX, IDC_FOLDER, m_folder);
- DDX_Control(pDX, IDC_PATH, m_path);
- DDX_Control(pDX, IDC_MYICON, m_icon);
- DDX_Control(pDX, IDC_DPDLG, m_dpdlg);
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CDirPickDlg, CDialog)
- //{{AFX_MSG_MAP(CDirPickDlg)
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDHOWDOI, OnHowdoi)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CDirPickDlg message handlers
-
- BOOL CDirPickDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
-
- m_caption.SetWindowText(m_dpdlg.GetCaption());
- m_bfc.SetCheck( (m_dpdlg.GetBrowseForComputer()) ? 1 : 0);
- m_bfp.SetCheck( (m_dpdlg.GetBrowseForPrinter()) ? 1 : 0);
- m_dgbd.SetCheck( (m_dpdlg.GetDontGoBelowDomain()) ? 1 : 0);
- m_rfsa.SetCheck( (m_dpdlg.GetReturnFSAncestors()) ? 1 : 0);
- m_rofsd.SetCheck( (m_dpdlg.GetReturnOnlyFSDirs()) ? 1 : 0);
- m_root.SetCurSel(m_dpdlg.GetRoot());
- m_root.SetDroppedWidth(200);
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
-
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
-
- void CDirPickDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
-
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CDirPickDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
-
- void CDirPickDlg::OnHowdoi()
- {
- CDialog dlg(IDD_DIRPICK_HOWDOI);
-
- dlg.DoModal();
- }
-
- void CDirPickDlg::OnOK()
- {
- CString caption;
- m_caption.GetWindowText(caption);
- m_dpdlg.SetCaption(caption);
- m_dpdlg.SetBrowseForComputer( (m_bfc.GetCheck() == 1) ? TRUE : FALSE);
- m_dpdlg.SetBrowseForPrinter( (m_bfp.GetCheck() == 1) ? TRUE : FALSE);
- m_dpdlg.SetDontGoBelowDomain( (m_dgbd.GetCheck() == 1) ? TRUE : FALSE);
- m_dpdlg.SetReturnFSAncestors( (m_rfsa.GetCheck() == 1) ? TRUE : FALSE);
- m_dpdlg.SetReturnOnlyFSDirs( (m_rofsd.GetCheck() == 1) ? TRUE : FALSE);
- m_dpdlg.SetRoot(m_root.GetCurSel());
-
- if (m_dpdlg.Show())
- {
- m_folder.SetWindowText(m_dpdlg.GetFolder());
- m_path.SetWindowText(m_dpdlg.GetPath());
- m_icon.SetIcon((HICON) m_dpdlg.GetIcon().GetHandle());
- }
- }
-